package com.jiezheng.huinong.action;

import org.apache.struts2.ServletActionContext;

import com.jiezheng.huinong.biz.ExportFile;
import com.opensymphony.xwork2.ActionSupport;

public class ReportManageAction extends ActionSupport {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 240426508342003203L;
	
	private String fileName = "";
	
	private static final String TMPLATE_PATH = "template/";
	
	private static final String DEST_FILE_NAME = "zhibiaotongji.xls";
	
	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String indexStatistic() {
		
		String filePath = getFilePath() + "//" + DEST_FILE_NAME;
		ExportFile.exportIndexStatisticFile(filePath, DEST_FILE_NAME);
		
		this.setFileName(DEST_FILE_NAME);
		return SUCCESS;
	}
	
	public String getFilePath() {
		return ServletActionContext.getServletContext().getRealPath(
				TMPLATE_PATH);
	}
}
